// pages/xiaoq/xiaoq.js
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        scrollLeft:0,
        StatusBar: app.globalData.StatusBar,
        CustomBar: app.globalData.CustomBar,
        num: 1,
        card:[],
        listArr:[]
    },
    toData : function(number){
      var n=number;
      var date = new Date(n);
      var Y = date.getFullYear() + '/';
      var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '/';
      var D = date.getDate()<10 ? '0'+date.getDate() : date.getDate();
      return (Y+M+D)
    },
    chaxun(){
      var that=this;
      wx.request({  
        url: 'https://www.woodymidnight.cn/BCUHelper/api/circle/selecallcircle',  
        method: 'POST',
        data:{
          circleType:1
        },                                      
        header: { 'content-type': 'application/x-www-form-urlencoded' }, 
        success: function (res) {   
          var resData = res.data;
          var data = res.data.data ;
          console.log("数据" , resData);
          console.log("this:",this);
          for(let i = 0 ; i < data.length ; i++){
            data[i].circletime = that.toData(data[i].circletime)
          }
          that.setData({
            card: resData.data.reverse()
          })

          let useCard = [];
          for(let i = 0 ; i < that.data.card.length ; i++){
            if(that.data.card[i].circletype == 0)
              useCard.push(that.data.card[i])
          }
          that.setData({
            listArr : useCard
          })
        }
      })
      
    },
    changeOne:function(e){
      let useCard = [];
      for(let i = 0 ; i < this.data.card.length ; i++){
        if(this.data.card[i].circletype == 0)
          useCard.push(this.data.card[i])
      }
      this.setData({
        num : 1 ,
        listArr : useCard
      })
    },
  
    changeTwo:function(e){
      let useCard = [];
      for(let i = 0 ; i < this.data.card.length ; i++){
        if(this.data.card[i].circletype == 1)
          useCard.push(this.data.card[i])
      }
      this.setData({
        num : 2 ,
        listArr : useCard
      })
    },
  
    changeThree:function(e){
      let useCard = [];
      for(let i = 0 ; i < this.data.card.length ; i++){
        if(this.data.card[i].circletype == 2)
          useCard.push(this.data.card[i])
      }
      this.setData({
        num : 3 ,
        listArr : useCard
      })
    },
      isCard(e) {
        this.setData({
          isCard: e.detail.value
        })
      },
      adddetial: function () {
        wx.navigateTo({
          url: '/pages/xqfb/xqfb',
          success: function (res) { },
          fail: function (res) { },
          complete: function (res) { },
        })
      },
      to(e){
        console.log(e);
        wx.navigateTo({
          url: '/pages/schoolxq/schoolxq?circleid='+e.currentTarget.dataset.circleid,
        })
      },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      this.chaxun();
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
      this.chaxun();
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})